package com.cybertron.ironhide.search.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.cybertron.ironhide.search.service.ProductService;

@Controller
@RequestMapping("/more")
public class MoreController {

	@Autowired(required = false)
	private ProductService productService;

	@RequestMapping(value = "/{type}/go", method = RequestMethod.POST)
	public String cate(
			@RequestParam(value = "keyWord", required = false) String keyWord,
			@RequestParam(value = "categoryId", required = false) String categoryId,
			String tag, @PathVariable("type") String type, Model model) {
		model.addAttribute("keyWord", keyWord);
		model.addAttribute("categoryId", categoryId);
		model.addAllAttributes(productService
				.getTags(keyWord, categoryId, type));
		return "more_" + type;
	}
}
